<#include "/common/_page.ftl"/>
<@page>
<form id="dataForm">
	<div align="center">
		<br/>
		<div style="width: 100%;" align="left">
			<#list createattributes  as item>
			 <#assign required=" ">
			 <#if item.required??&&item.required=="true">
			 	<#assign required=",required:true">
			 </#if>
			
			<#assign index=item_index+1>
			<#assign cwidth="200px">
			<#switch item.datatype>
			  <#case "text">
			    <input id="form_${item.name}" name="form.${item.name}" class="easyui-textbox" data-options="label:'${item.label}：',labelAlign:'right'${required}" style="width:${cwidth}"> 
			    <#break>
			  <#case "email">
			  	<input id="form_${item.name}" name="form.${item.name}" class="easyui-textbox" data-options="label:'${item.label}：',labelAlign:'right', validType:['email','length[0,20]']${required}" style="width:${cwidth}">
			    <#break>
			  <#case "number">
			    <input id="form_${item.name}" name="form.${item.name}" class="easyui-numberbox" data-options="label:'${item.label}：',labelAlign:'right'${required}" style="width:${cwidth}"> 
			    <#break>
			  <#case "file">
			    <input id="form_${item.name}" name="form.${item.name}" class="easyui-filebox" data-options="label:'${item.label}：',labelAlign:'right',buttonText: '选择文件', buttonAlign: 'left' ${required}" style="width:${cwidth}"> 
			    <#break>
			  <#case "date">
			    <input id="form_${item.name}" name="form.${item.name}" class="easyui-datetimebox" data-options="label:'${item.label}：',labelAlign:'right'" style="width:${cwidth}"> 
			    <#break>
			  <#case "photo">
			    <input id="form_${item.name}" name="form.${item.name}" class="easyui-filebox" data-options="label:'${item.label}：',labelAlign:'right',buttonText: '选择文件', buttonAlign: 'left',accept:'image/jpeg' ${required}" style="width:${cwidth}"> 
			    <#break>
			  <#case "password">
			    <input id="form_${item.name}" name="form.${item.name}" class="easyui-passwordbox" prompt="Password" data-options="label:'${item.label}：',labelAlign:'right' ${required}" style="width:${cwidth}"> 
			    <#break>
			  <#default>
			   	<input id="form_${item.name}" name="form.${item.name}" class="easyui-textbox" data-options="label:'${item.label}：',labelAlign:'right'${required}" style="width:${cwidth}"> 
			</#switch>
			<#if index%2==0>
				<br/>
			</#if>
			</#list>
		</div>
	</div>
	<br/>
	<div align="center">
		  <button type="button"  name="btnClose"  class="btn btn-primary btn-sm" onclick="closeCreateDialog()">关闭</button>
		  <button type="button" name="btnSubmit" class="btn btn-primary btn-sm" onclick="submitForm()">提交</button>
	</div>
</form>
	<script type="text/javascript">
 	$(function(){
 	});
 	function closeCreateDialog(){
 		 $("#${dialogid}").dialog("close");
 		 $("#${dialogid}").dialog("clear"); 
 	}
 	function submitForm(){	
 		 var isValid = $('#dataForm').form('validate');
 		 console.log(isValid);
 		 if(isValid){ 		 
			 var url='${currentPath}/save?type=${currentType}';
			 console.log(url);
			 var data = decodeURIComponent($('#dataForm').serialize(),true);
			 $.post(url,data,function(result){
			 	 console.log(result);
				 $("#${dialogid}").dialog("close");
				 $("#${tableid}").datagrid('reload'); 
			 });
 		 }
 	}
 	</script>	
</@page>
